Skip to content

perf(streams): avoid repeated growing-buffer prefix extraction in SSE decoding - #7676

Merged
lidge-jun merged 2 commits into
lidge-jun:devfrom
luvs01:perf/sse-bounded-line-prefix
Oct 24, 2026
Merged

lidge-jun merged 2 commits into
lidge-jun:devfrom
luvs01:perf/sse-bounded-line-prefix

Conversation

@luvs01

@luvs01 luvs01 commented Oct 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Keep only the bounded six-code-unit prefix needed to recognize an SSE data: field instead of repeatedly extracting that prefix from a growing line. Update the prefix after accepted appends and reset it at each accepted line.

Preserve CR, LF and split-CRLF handling, UTF-8 decoding, byte accounting, event limits and translator-budget admission/release. Extend regressions for fragmented long lines, multilingual fields and failure cleanup.

Verification

  • HEAD c7607ae0e41d971529ba05b731945b73b8735953 normally merges source 4771faba9eaf395e9ba58e83c185a1dee1b3e26f with dev@bd5c2ea906741a4201c6f35bb180e7a9a112a4fd. Both change-owned blobs are unchanged; root/GUI dependency inputs match dev.
  • Official Bun 1.4.4, native Windows, CI=1: bun test --isolate --timeout 60000 tests/responses/sse-carriage-return.test.ts tests/responses/sse-decoder.test.ts — 25 passed / 0 failed / 277 assertions. This includes acceptance at exactly 32 MiB and rejection at one byte above the limit.
  • Root TypeScript, Structure and diff checks passed. Repository privacy/file-size evaluators passed over both changed files; unrelated sparse-absent paths were not evaluated.
  • Existing isolated frozen dependencies matched current inputs and installed manifests; no reinstall or live settings change. Source clean and owned processes/fixtures absent after validation.
  • Source review checked successful-append ordering, line reset, delimiters, Unicode and unchanged admission/release behavior. Existing Structure contracts remain accurate. The operation-count regression distinguishes repeated growing-line prefix extraction; it does not establish total worst-case copying, process RSS or end-to-end throughput.
  • Full-suite exception: focused regression and static checks were used alongside other worktrees. Complete-suite and native macOS/Linux runs, benchmarks and new upstream CI remain pending. Earlier source-head CI is historical, not current-merge success.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Co-authored-by: luvs01 27862058+luvs01@users.noreply.github.com

luvs01 and others added 2 commits October 23, 2026 23:17
Avoid re-slicing the growing line buffer for every incoming fragment.
Keep at most six code units for field classification and reset on each
accepted line, preserving existing UTF-8 accounting and admission order.
Add fragmented-prefix, Unicode, operation-count and failure-cleanup tests.

Co-authored-by: luvs01 <27862058+luvs01@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the enhancement New feature or request label Oct 24, 2026
@lidge-jun
lidge-jun marked this pull request as ready for review October 24, 2026 17:51
@lidge-jun

Copy link
Copy Markdown
Owner

Integration evidence (owner decision decision:e6895606, approved): independent gpt-6.1-sol review PASS at c7607ae (bounded six-code-unit prefix, fragmented/Unicode coverage, admission-failure cleanup). Exact-head CI run 40079749137 succeeded: four Ubuntu test shards, gates and aggregate ci. Not Windows-sensitive.

Static merge simulation on current dev d0a8443 (this Mac): dev=d0a84439cee1427cc02397f54084aa3d145eda04 base=bd5c2ea906741a4201c6f35bb180e7a9a112a4fd pr_files= 2 overlap=[]; merge clean; install exit=0; gui install exit=0; tsc exit=0; tsc doctor exit=0; structure:check exit=0; privacy:scan exit=0; layout+ratchet guards exit=0 52 pass 0 fail ;

Merged by the triage manager as maintainer integration (MAINTAINERS.md, dev only) with green exact-head PR CI, an independent review PASS, and the owner's approval of this bundle.

@lidge-jun
lidge-jun merged commit 26598df into lidge-jun:dev Oct 24, 2026
30 of 32 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-24T17:53:04.532157Z
We couldn’t complete this review. Comment @codex review to try again.
c7607ae Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

luvs01 added a commit to luvs01/opencodex that referenced this pull request Oct 24, 2026
Brings the PR7635 follow-up candidate onto current dev (SSE field
prefix fix lidge-jun#7676 and ancestors). Clean merge; the two review-nit
changes are unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants